var zjmultiplequery='';
//var returnMes = '无法检索到运单。';
var timeoutcss = 6000;
//utils-vue
function trimKG(str){
    return str.replace(/(^\s*)|(\s*$)/g, "");
}
//vue
// function queryMul() {
//     var multiplequerywaybillno = trimKG($(".multiplequerywaybillno").val());
//
//     var mulcssstr = checkWaybillV1(multiplequerywaybillno);
//
//     var cssPDselectStr = $(".input-group-select .dropdown .dropdown-toggle").html();
//     $(".search-null").slideUp("500");
//     if("运单/订单"==cssPDselectStr.substr(0,5)){
//         console.log("切换到运单/订单");
//         if(mulcssstr==""){
//             checktip($('.multiplequerywaybillno'), '请输入运单/订单号');
//         }
//         if('YD'==mulcssstr){
//             console.log("查询运单！");
//             //点击运单查询的时候，如果订单打开，则隐藏订单内容   //868686005 868686004  868686003
//             var ddstrcss = $(".csssuper-order").css("display");
//             if('block'==ddstrcss){
//                 $(".csssuper-order").css("display","none");
//             }
//
//             setWaybillNoMul(multiplequerywaybillno);
//
//             queryIsEcsOrFoss(multiplequerywaybillno);
//
//         }else if ('DD'==mulcssstr){
//             console.log("查询订单！");
//             //点击订单查询的时候，如果运单打开，则隐藏运单内容
//             var ddstrcss = $(".csssuper").css("display");
//             if('block'==ddstrcss){
//                 $(".csssuper").css("display","none");
//             }
//
//             $.ajax({
//                 url: OMS_SERVER_NAME+"oms-ltl-web/uaporder/queryAllByOrderNumber.action",
//                 type: "POST",
//                 //dataType: "json",
//                 //contentType: "application/json",  // "Y170722031549750508"   Y170730163033416971
//                 data:{"uapOrderVO.ltlOrder.orderNumber":multiplequerywaybillno},
//                 success: function (r) {
//
//                     console.log("渲染订单查询方法开始！");
//                     if(r==null||r==''||r.uapOrderVO.uapSearchOrder==null){
//                         $(".csssuper-order").css("display","none");
//                         // showMsg('success', '此订单不存在！');
//                         $(".search-null").slideDown("500");
//                     }else{
//                         $(".search-null").slideUp("500");
//                         $(".csssuper-order").css("display","block");
//                         $(r.uapOrderVO.uapSearchOrder).each(function (i, d) {
//
//                             var omsXTstr = "零担订单受理";
//                             var omsXTurl = "";
//                             for(var k in d) {
//                                 if(k=="isReceiveGoods"){
//                                     $(".csssuper-order ."+k).html("非上门取货");
//                                 }else if(k=="orderType"){
//                                     if("exp"==d["orderType"]){
//                                         omsXTstr = "快递订单受理";
//                                     }
//                                 }else if(k=="orderAcceptURL"){
//                                     omsXTurl = d["orderAcceptURL"];
//                                 }else if(k=="waybillNumber"){
//                                     var waybillNumberFalse = d["waybillNumber"];
//                                     if(null==waybillNumberFalse||''==waybillNumberFalse||'undefined'==waybillNumberFalse){
//                                         $(".waybill-num").css("display","none");
//                                         $(".csssuper-order .waybillNumber").html('无');
//                                     }else{
//                                         $(".waybill-num").css("display","block");
//                                         $(".csssuper-order .waybillNumber").html(waybillNumberFalse);
//                                     }
//
//                                 }else if(k=="feedbackInfo"){
//                                     var feedbackInfonull = d["feedbackInfo"];
//                                     if(feedbackInfonull==''||null==feedbackInfonull){
//                                         $(".csssuper-order .feedbackInfo").html("无");
//                                         $('.csssuper-div-fd').hide();//信息无隐藏
//                                     }else{
//                                         $(".csssuper-order .feedbackInfo").html(feedbackInfonull);
//                                     }
//                                 }
//                                 else if(k=="createTime"){
//                                     var feedbackInfonull = d["createTime"];
//                                     var createDate = new Date(feedbackInfonull);
//                                     var beforetime = createDate.format("yyyy-MM-dd");
//                                     var aftertime = returnTimeTwoStrMul(createDate.getHours()) + ":" + returnTimeTwoStrMul(createDate.getMinutes());
//                                     $(".csssuper-order .beforetime").html(beforetime);
//                                     $(".csssuper-order .aftertime").html(aftertime);
//                                 }
//                                 else{
//                                     if(d[k]!=null){
//                                         if(d[k]!=""){
//                                             $(".csssuper-order ."+k).html(d[k]);
//                                         }
//                                     }
//                                 }
//                             }
//
//                             $(".csssuper-order .orderAcceptURL").click(function(){
//                                 orderOMSTo(omsXTstr,omsXTurl,multiplequerywaybillno);
//                             });
//                         })
//
//                     }
//
//                 },
//                 error: function (httpRequest) {
//                     $(".csssuper-order").css("display","none");
//                     showMsg('warn', '订单系统维护中 !');
//                     console.log("渲染订单查询方法失败！");
//                 }
//             });
//
//             // var ddstrcss = $(".csssuper-order").css("display");
//             // if('none'==ddstrcss){
//             //     $(".csssuper-order").css("display","block");
//             // }else{
//             //     $(".csssuper-order").css("display","none");
//             // }
//
//             //设置订单号
//             $(".csssuper-order .mulwbn").html(multiplequerywaybillno);
//
//         }else if ('QT'==mulcssstr){
//             console.log("请输入运单/订单号");
//             $(".csssuper-order").css("display","none");
//             $(".csssuper").css("display","none");
//             $(".search-null").slideDown("500");
//         }
//
//
//     }else if("人员"==cssPDselectStr.substr(0,2)){
//         //点击人员查询的时候，如果人员打开，则隐藏人员内容
//         // $(".oaClerkSearch").slideToggle("500");
//         console.log("切换到人员");
//         if(multiplequerywaybillno == ''){
//             checktip($('.multiplequerywaybillno'), '请输入人员');
//         }else{
//             queryAddressListByName(multiplequerywaybillno);
//         }
//     }else if("部门"==cssPDselectStr.substr(0,2)){
//
//         //判断搜索的部门类型
//         // $(".oaDepartSearch").slideToggle("500");
//         console.log("切换到部门");
//         if(multiplequerywaybillno == ''){
//             checktip($('.multiplequerywaybillno'), '请输入部门');
//         }else{
//             queryAddressListByDept(multiplequerywaybillno,0);
//         }
//     }
// };
//vue
// function keyDown(e) {
//     $(".search-null").slideUp("500");
//     var ev= window.event||e;
//     if (ev.keyCode == 13) {
//
//         var multiplequerywaybillno = trimKG($(".multiplequerywaybillno").val());
//
//         var mulcssstr = checkWaybillV1(multiplequerywaybillno);
//
//         var cssPDselectStr = $(".input-group-select .dropdown .dropdown-toggle").html();
//
//         if("运单/订单"==cssPDselectStr.substr(0,5)){
//             console.log("切换到运单/订单");
//             if(mulcssstr==""){
//                 checktip($('.multiplequerywaybillno'), '请输入运单/订单号');
//             }
//             if('YD'==mulcssstr){
//                 console.log("查询运单！");
//                 //点击运单查询的时候，如果订单打开，则隐藏订单内容   //868686005 868686004  868686003
//                 var ddstrcss = $(".csssuper-order").css("display");
//                 if('block'==ddstrcss){
//                     $(".csssuper-order").css("display","none");
//                 }
//
//                 setWaybillNoMul(multiplequerywaybillno);
//
//                 queryIsEcsOrFoss(multiplequerywaybillno);
//
// //                if(flag){
// //
// //                } else {
// //                    dealShowFirstMenu();
// //                }
//
//             }else if ('DD'==mulcssstr){
//                 console.log("查询订单！");
//
//                 //点击订单查询的时候，如果运单打开，则隐藏运单内容
//                 var ddstrcss = $(".csssuper").css("display");
//                 if('block'==ddstrcss){
//                     $(".csssuper").css("display","none");
//                 }
//
//                 $.ajax({
//                     url: OMS_SERVER_NAME+"oms-ltl-web/uaporder/queryAllByOrderNumber.action",
//                     type: "POST",
//                     //dataType: "json",
//                     //contentType: "application/json",  // "Y170722031549750508"   Y170730163033416971
//                     data:{"uapOrderVO.ltlOrder.orderNumber":multiplequerywaybillno},
//                     success: function (r) {
//
//                         console.log("渲染订单查询方法开始！");
//                         if(r==null||r==''||r.uapOrderVO.uapSearchOrder==null){
//                             $(".csssuper-order").css("display","none");
//                             $(".search-null").slideDown("500");
//                         }else{
//                             $(".search-null").slideUp("500");
//                             $(".csssuper-order").css("display","block");
//                             $(r.uapOrderVO.uapSearchOrder).each(function (i, d) {
//
//                                 var omsXTstr = "零担订单受理";
//                                 var omsXTurl = "";
//                                 for(var k in d) {
//                                     if(k=="isReceiveGoods"){
//                                         $(".csssuper-order ."+k).html("非上门取货");
//                                     }else if(k=="orderType"){
//                                         if("exp"==d["orderType"]){
//                                             omsXTstr = "快递订单受理";
//                                         }
//                                     }else if(k=="orderAcceptURL"){
//                                         omsXTurl = d["orderAcceptURL"];
//                                     }else if(k=="waybillNumber"){
//                                         var waybillNumberFalse = d["waybillNumber"];
//                                         if(null==waybillNumberFalse||''==waybillNumberFalse||'undefined'==waybillNumberFalse){
//                                             $(".waybill-num").css("display","none");
//                                             $(".csssuper-order .waybillNumber").html('无');
//                                         }else{
//                                             $(".waybill-num").css("display","block");
//                                             $(".csssuper-order .waybillNumber").html(waybillNumberFalse);
//                                         }
//
//                                     }else if(k=="feedbackInfo"){
//                                         var feedbackInfonull = d["feedbackInfo"];
//                                         if(feedbackInfonull==''||null==feedbackInfonull){
//                                             $('.csssuper-div-fd').hide();//反馈信息没有时不显示
//                                             $(".csssuper-order .feedbackInfo").html("无");
//                                         }else{
//                                             $(".csssuper-order .feedbackInfo").html(feedbackInfonull);
//                                         }
//                                     }
//                                     else if(k=="createTime"){
//                                         var feedbackInfonull = d["createTime"];
//                                         var createDate = new Date(feedbackInfonull);
//                                         var beforetime = createDate.format("yyyy-MM-dd");
//                                         var aftertime = returnTimeTwoStrMul(createDate.getHours()) + ":" + returnTimeTwoStrMul(createDate.getMinutes());
//                                         $(".csssuper-order .beforetime").html(beforetime);
//                                         $(".csssuper-order .aftertime").html(aftertime);
//                                     }
//                                     else{
//                                         if(d[k]!=null){
//                                             if(d[k]!=""){
//                                                 $(".csssuper-order ."+k).html(d[k]);
//                                             }
//                                         }
//                                     }
//                                 }
//
//                                 $(".csssuper-order .orderAcceptURL").click(function(){
//                                     orderOMSTo(omsXTstr,omsXTurl,multiplequerywaybillno);
//                                 });
//                             })
//
//                         }
//
//                     },
//                     error: function (httpRequest) {
//                         $(".csssuper-order").css("display","none");
//                         showMsg('warn', '订单系统维护中 !');
//                         console.log("渲染订单查询方法失败！");
//                     }
//                 });
//
//                 // var ddstrcss = $(".csssuper-order").css("display");
//                 // if('none'==ddstrcss){
//                 //     $(".csssuper-order").css("display","block");
//                 // }else{
//                 //     $(".csssuper-order").css("display","none");
//                 // }
//
//                 //设置订单号
//                 $(".csssuper-order .mulwbn").html(multiplequerywaybillno);
//
//             }else if ('QT'==mulcssstr){
//                 console.log("无法检索查询结果");
//                 $(".csssuper-order").css("display","none");
//                 $(".csssuper").css("display","none");
//                 $(".search-null").slideDown("500");
//             }
//
//
//         }else if("人员"==cssPDselectStr.substr(0,2)){
//             //点击人员查询的时候，如果人员打开，则隐藏人员内容
//             // $(".oaClerkSearch").slideToggle("500");
//             if(multiplequerywaybillno == ''){
//                 checktip($('.multiplequerywaybillno'), '请输入人员');
//             }else{
//                 queryAddressListByName(multiplequerywaybillno);
//             }
//             console.log("切换到人员");
//         }else if("部门"==cssPDselectStr.substr(0,2)){
//             //判断搜索的部门类型
//             // $(".oaDepartSearch").slideToggle("500");
//             if(multiplequerywaybillno == ''){
//                 checktip($('.multiplequerywaybillno'), '请输入部门');
//             }else{
//                 queryAddressListByDept(multiplequerywaybillno,0);
//             }
//             console.log("切换到部门");
//         }
//
//
//
//     }
// };

function orderOMSTo(name,url,ddno){
  if("零担订单受理" == name){
        var urlgd = OMS_SERVER_NAME +'oms-ltl-web/uaporder/uaporder.action';
        viewTab(name,urlgd,'div',{'orderNumber':ddno});
    }else{
        viewTab(name,url,'div',{'orderVo.orderEntity.orderNumber':ddno});
    }

    //
}

function queryIsMulOpen(){
    var block =  $(".csssuper").css("display");
    // $(".csssuper").css("left",$('#selemenu .multiplequerywaybillno').position().left+'px');
    var bool = false;
    if(block=='block'){
        bool= true;
    }
    return bool;
}

//vue
function setWaybillNoMul(multiplequerywaybillno){

    var abccss = multiplequerywaybillno;
    if(multiplequerywaybillno.length>0){
        abccss =   substrWaybillNo(multiplequerywaybillno)
    }
    $(".csssuper .mulwbn").html(abccss);
}

//vue
function queryIsEcsOrFoss(waybill) {
    $.ajax({
        url: FOSS_BASE_MUL_PATH+"bse-querying-web/login/queryBseSwitch4Ecs.action?waybillNo="+waybill,
        type: "POST",
        dataType: "json",
        contentType: "application/json",
        //data: {"waybillNo" : tt },
        success: function (r) {
            //用户未登录异常
            if("获取用户信息失败，请尝试清理Cookie或者重启浏览器!"==r){
                // dealShowFirstMenu();
                showMsg('warn', '获取用户信息失败,请尝试清理Cookie或者重启浏览器！');
                $('.csssuper').slideUp();
            }else{
                console.log("[运单号]:"+waybill+"是否ECS单号："+r.ecsSwitch+"[open]:"+queryIsMulOpen()+"[中间运单]:"+zjmultiplequery);
                var ECSmul =ECS_BASE_MUL_PATH+"qmc-query-web/zsource/queryBseindex.action";
                var FOSSmul =FOSS_BASE_MUL_PATH+"bse-querying-web/querying/integrativeQueryIndex.action?fullScreen=true";

                var EFcsslisstr ="<h1>搜索结果</h1><a class='multiple-EF-queryAll' href='JavaScript:void(0)' onclick=\"closeTab(\'"+FOSSmul+"\',\'DIV\');viewTab(\'" + "综合查询" + "\',\'" + FOSSmul + "\',\'DIV\',{\'waybillNumber\':"+waybill+"})\">查看完整信息&gt;</a>"

                if('Y' == r.ecsSwitch){
                    EFcsslisstr ="<h1>搜索结果</h1><a class='multiple-EF-queryAll' href='JavaScript:void(0)' onclick=\"closeTab(\'"+ECSmul+"\',\'DIV\');viewTab(\'" + "悟空-快递综合查询" + "\',\'" + ECSmul + "\',\'DIV\',{\'waybillNumber\':"+waybill+"})\">查看完整信息&gt;</a>"
                    $(".multiple-EF-queryAll-title").empty();
                    $(".multiple-EF-queryAll-title").append(EFcsslisstr);

                    if(waybill!=zjmultiplequery){
                        queryEcsMul(waybill);
                    }else {
                        $('.csssuper').slideDown();
                    }
//                    if(queryIsMulOpen()){
//                    	if(waybill!=zjmultiplequery){
//                            queryEcsMul(waybill);
//                        }
//                        //dealShowFirstMenu();
//
//                    }

                }else{
                    $(".multiple-EF-queryAll-title").empty();
                    $(".multiple-EF-queryAll-title").append(EFcsslisstr);

                    //if(queryIsMulOpen()){
                    if(waybill!=zjmultiplequery){
                        queryFossMul(waybill);
                    }else {
                        $('.csssuper').slideDown();
                    }

                    //}

                }

                zjmultiplequery = waybill;
            }


        },
        error: function (httpRequest) {
            // dealShowFirstMenu();
//           $(".input-tip").css("display","block");
//     	   $(".input-tip").html("查询失败！");
            $('.csssuper').slideUp();
            showMsg('warn', '该运单是所在系统判断，接口来查询失败！');
            console.log("该运单是所在系统判断，接口来查询失败！");
        }
    });
}

function queryEcsMul(e) {
    console.log("调用ECS综合查询-【运单号】："+e);
    $(".gjmultiple").empty();
    $(".gzjlmultiple").empty();
    var waybillNodata = {
        'waybillNo': e
    };
    //5183824066  5801023718  "5801023718"
    var conditiondata = {
        'condition': waybillNodata
    };
    var waybillVodata = {
        'waybillVo': conditiondata
    };
    var requestcss = JSON.stringify(waybillVodata);
    $.ajax({
        url: ECS_BASE_MUL_PATH+"qmc-query-web/zsource/searchWaybillInfoByWaybillNo.action",
        type: "POST",
        dataType: "json",
        contentType: "application/json",
        data: requestcss,
        success: function (r) {
            if(null==r.waybillVo||'undefined'==r.waybillVo){
                console.log("跟踪记录内容为空！");
            }else{
                $('.csssuper').slideDown();
                $.multiplecss(r.waybillVo.waybillInfoByWaybillNoReultDto);
            }

            //dealShowFirstMenu();
        },
        error: function (httpRequest) {
            //$(".input-tip").css("display","block")
            //$(".input-tip").html("调用ECS运单接口失败！");
            console.log("调用ECS运单接口失败！");
        }
    });
    $.ajax({
        url: ECS_BASE_MUL_PATH+"qmc-query-web/zsource/searchWaybillNbgjByWaybillNo.action",
        type: "POST",
        dataType: "json",
        contentType: "application/json",
        data: requestcss,
        success: function (r) {  //wayBIllNoLocusList
            //queryecsdictory(r.waybillVo.wayBIllNoLocusList);
            //$(".gjmultiple").nextAll().remove();
            $.multiplegjecs(r.waybillVo.wayBIllNoLocusList);
            $('.csssuper').slideDown();
        },
        error: function (httpRequest) {
            //$(".input-tip").css("display","block")
            //$(".input-tip").html("调用ECS运单轨迹接口失败！");
            console.log("调用ECS运单轨迹接口失败！");
        }
    });
    $.ajax({
        url: ECS_BASE_MUL_PATH+"qmc-query-web/zsource/queryWayBilllTrackRecords.action",
        type: "POST",
        dataType: "json",
        contentType: "application/json",
        data: requestcss,
        success: function (r) {
            var trackRlMsg = r.message;
            if('服务端未知异常'==trackRlMsg){
                console.log("悟空跟踪记录接口调用失败！");

            }else{
                //$(".gjmultiple tbody").remove();
                $.multiplegzjl(r.waybillVo.trackRecordList);
                $('.csssuper').slideDown();
            }
        },
        error: function (httpRequest) {
            //$(".input-tip").css("display","block")
            //$(".input-tip").html("调用ECS运单轨迹接口失败！");
            //$(".multiplequerywaybillno").addClass('error');
            console.log("调用ECS运单轨迹接口失败！");
        }
    });
    $.extend({
        multiplecss: function (rs) {
            $(rs).each(function (i, d) {
                for(var k in d) {

                    var ss = $("."+k)[0];
                    if(ss=="undefined"||null==ss){
                    }else{
                        if(d[k]!=null){
                            if(d[k]!=""){
                                $("."+k).html(d[k]);
                            }
                        }
                    }
                }
            })
        }
    });
    $.extend({
        multiplegzjl: function (rs) {
            var lis = "";
            $(rs).each(function (i, d) {
                if(null==d){
                    return;
                }
                var createTimeStr = d.createTime+"";

                if(createTimeStr!=null&&createTimeStr!=''){
                    if(createTimeStr>999999999){
                        createTimeStr = parseInt(createTimeStr/1000);
                    }
                }

                var acceptedTimeStr = d.acceptedTime+"";

                if(acceptedTimeStr!=null&&acceptedTimeStr!=''){
                    if(acceptedTimeStr>999999999){
                        acceptedTimeStr = parseInt(acceptedTimeStr/1000);
                    }
                }


                var unixTimestamp = new Date( createTimeStr*1000 ) ;
                var commonTime = unixTimestamp.toLocaleString();
                var datestrformate = commonTime.split("&");
                var unixTimestampsl = new Date( acceptedTimeStr*1000 ) ;
                var commonTimesl = unixTimestampsl.toLocaleString();
                var datestrformatesl = commonTimesl.split("&");

                var qctime ="";
                (null == d.createTime) ? qctime = "" : qctime =  "<label>起草</label>"+datestrformate[0]+" "+datestrformate[1];

                var sltime="";
                (null == d.acceptedTime) ? sltime = "" : sltime = "<label>受理</label>"+datestrformatesl[0]+" "+datestrformatesl[1];

                var contentgzjl = d.trackContent;
                (null == d.trackContent) ? contentgzjl = "" : contentgzjl = d.trackContent;

                var createOrgNamegzjl = d.createOrgName;
                (null == d.createOrgName) ? createOrgNamegzjl = "" : createOrgNamegzjl = d.createOrgName;

                var acceptedOrgNamegzjl = d.acceptedOrgName;
                (null == d.acceptedOrgName) ? acceptedOrgNamegzjl = "" : acceptedOrgNamegzjl = d.acceptedOrgName;

                var imgstrone =  "<img src='resources/img/multiple/mul-zdfour-gzjl.png' />";

                lis ="<TR class='full'><TD class='trajectory-font'>"+imgstrone+"<span title=' "+contentgzjl+" '>"+controlLength(contentgzjl,30)+"</span></TD><TD class='trajectory-info dept'><span>"+qctime+"</span><p>"+controlLength(createOrgNamegzjl,14)+"</p></TD>"+"</TD><TD class='trajectory-info'><span>"+sltime+"</span><p>"+controlLength(acceptedOrgNamegzjl,14)+"</p></TD></TR>";

                $(".gzjlmultiple").prepend(lis);
            })
            return lis;

        }
    });
    $.extend({
        multiplegjecs: function (rs) {
            var lis = "";

            $(rs).each(function (i, d) {
                var imgstrone =  "<img src='resources/img/multiple/mul-zdthree.png' />";
                var topstr = "bottom";
                var blackcss ="";
                if(i==0){
                    imgstrone =  "<img src='resources/img/multiple/mul-zdone.png' />";
                    blackcss =" black";
                }

                var operateTimeStr = d.operateTime;

                if(operateTimeStr!=null&&operateTimeStr!=''){
                    if(operateTimeStr>999999999){
                        operateTimeStr =parseInt(operateTimeStr/1000) ;
                    }
                }

                var unixTimestamp = new Date( operateTimeStr*1000 ) ;
                var commonTime = unixTimestamp.toLocaleString();
                var datestrformate = commonTime.split("&");

                var hwgjstr = queryGjhwzt(d.currentStatus);
                var czgjstr = queryGjczzt(d.operateTypeName);

                lis ="<TR class='full'><TD class='trajectory-time'><p>"+datestrformate[0]+"</p><span>"+datestrformate[1]+"</span> </TD><TD class='trajectory-font"+blackcss+"'>"+imgstrone+"<span class=\'css "+d.currentStatus+"\'  title='"+hwgjstr+"'>"+hwgjstr+"</span><span class='css'><label class='operateOrgName' title='"+d.operateOrgName+"'>"+" "+d.operateOrgName+"</label><label class='operateName' title='"+d.operateName+"'>"+d.operateName+"</label><label class='czgjstr' title='"+czgjstr+"'>"+czgjstr+"</label></span></TD></TR>";
                $(".gjmultiple").append(lis);

            })
            return lis;
        }
    });
    function queryecsdictory(rs) {
        var dicurl =ECS_BASE_MUL_PATH+"qmc-query-web/dict/loadDictionaryByType.action";
        dicurl += "&code="+"GOODS_TYPE";
        if(rs==null||rs==''){
        }else{
            $.ajax({
                url: dicurl,
                type: "GET",
                dataType: "json",
                contentType: "application/json",
                async : "false",
                success: function (r) {
                    $(rs).each(function (i, d) {
                        var currentstatus =  d.currentStatus;
                        var datadictoryinner = r.dictionaryVo.dictionaryList;
                        for(var k in datadictoryinner) {
                            var dicstr = datadictoryinner[k].valueCode;
                            if(currentstatus==dicstr){
                                var imgstrone =  "<img src='resources/img/multiple/mul-zdthree.png' />";
                                var topstr = "bottom";
                                var blackcss ="";
                                if(i==0){
                                    imgstrone =  "<img src='resources/img/multiple/mul-zdone.png' />";
                                    topstr ="top";
                                    blackcss =" black";
                                }

                                var operateTimeStr = d.operateTime;

                                if(operateTimeStr!=null&&operateTimeStr!=''){
                                    if(operateTimeStr>999999999){
                                        operateTimeStr = parseInt(operateTimeStr/1000) ;
                                    }
                                }

                                var unixTimestamp = new Date( operateTimeStr*1000 ) ;
                                var commonTime = unixTimestamp.toLocaleString();
                                var datestrformate = commonTime.split("&");

                                lis ="<TR class='full'><TD class='trajectory-time'><p>"+datestrformate[0]+"</p><span>"+datestrformate[1]+"</span> </TD><TD class='trajectory-font"+blackcss+"'>"+imgstrone+"<span class='css'>"+datadictoryinner[k].valueName+" "+d.operateTypeName+" "+d.operateOrgName+"</span></TD></TR>";
                                $(".gjmultiple").append(lis);
                            }
                        }
                    })
                },
                error: function (httpRequest) {
                    console.log("ECS服务未知异常！");
                }
            });
        }

    };
}

function queryFossMul(e) {
    console.log("调用FOSS综合查询-【运单号】："+e);
    $(".gjmultiple").empty();
    $(".gzjlmultiple").empty();
    var waybillNodata = {
        'waybillNo':  e
    };
    var conditiondata = {
        'condition': waybillNodata
    };
    var waybillVodata = {
        'waybillVo': conditiondata
    };
    var requestcss = JSON.stringify(waybillVodata);
    $.ajax({
        url: FOSS_BASE_MUL_PATH+"bse-querying-web/querying/searchWaybillInfoByWaybillNo.action",
        type: "POST",
        dataType: "json",
        contentType: "application/json",
        timeout : timeoutcss,
        //data: {"waybillVo.condition.waybillNo":e},
        data: requestcss,
        success: function (r) {
            var returnMes = r.message;
            if('无法检索到运单。'== returnMes){
                console.log("无法检索到此运单结果!");
                //$(".input-tip").css("display","block");
                //$(".input-tip").html("系统无法检索到运单");
                // $(".multiplequerywaybillno").addClass('error');
                zjmultiplequery='';
                $('.csssuper').slideUp();
                $(".search-null").slideDown("500");
//            	$(".csssuper").css("display","none");
                //dealShowFirstMenu();
            }else{
                $(".search-null").slideUp("500");
                $('.csssuper').slideDown();
                $.multiplecss(r.waybillVo.waybillInfoByWaybillNoReultDto);
                //$(".gjmultiple tbody").remove();
                $.multiplegj(r.waybillVo.wayBIllNoLocusList);
                //dealShowFirstMenu();
            }
        },
        error: function (httpRequest) {
            $('.csssuper').slideUp();
            console.log("waybill提交未知异常！");
            showMsg("warn","系统在维护中！");
        }

    });

    $.ajax({
        url: FOSS_BASE_MUL_PATH+"bse-querying-web/querying/queryWayBilllTrackRecords.action",
        type: "POST",
        dataType: "json",
        contentType: "application/json",
        //data: {"waybillVo.condition.waybillNo":e},
        data: requestcss,
        success: function (r) {
            $.multiplegzjlfoss(r.waybillVo.trackRecordList);
        },
        error: function (httpRequest) {
            console.log("waybill提交未知异常！");
        }
    });



    $.extend({
        multiplecss: function (rs) {
            $(rs).each(function (i, d) {
                for(var k in d) {
                    var ss = $("."+k)[0];
                    if(ss=="undefined"||null==ss){
                    }else{
                        if(d[k]!=null){
                            if(d[k]!=""){
                                $("."+k).html(d[k]);
                            }
                        }
                    }
                }
            })
        }
    });

    $.extend({
        multiplegj: function (rs) {
            //$(".gjmultiple").nextAll().remove();
            var lis = "";
            var sumsize = 0 ;
            if(null==rs||'undefined'==rs){

            }else{
                sumsize = rs.length-2
            }

            $(rs).each(function (i, d) {
                if(null==d){
                    return;
                }
                var imgstrone =  "<img src='resources/img/multiple/mul-zdthree.png' />";
                var topstr = "bottom";
                var blackcss ="";

                if(i==sumsize){
                    imgstrone =  "<img src='resources/img/multiple/mul-zdone.png' />";
                    topstr ="top";
                    blackcss =" black";

                }
                var operateTimeStr = d.operateTime;

                if(operateTimeStr!=null&&operateTimeStr!=''){
                    if(operateTimeStr>999999999){
                        operateTimeStr =parseInt(operateTimeStr/1000) ;
                    }
                }

                var unixTimestamp = new Date( operateTimeStr*1000 ) ;
                var commonTime = unixTimestamp.toLocaleString();
                var datestrformate = commonTime.split("&");
                lis ="<TR class='full'><TD class='trajectory-time'><p>"+datestrformate[0]+"</p><span>"+datestrformate[1]+"</span> </TD><TD class='trajectory-font"+blackcss+"'>"+imgstrone+"<span class=\'css "+d.currentStatus+"\' title='"+d.currentStatus+"'>"+d.currentStatus+"</span><span class='css'><label class='operateOrgName' title='"+d.operateOrgName+"'>"+" "+d.operateOrgName+"</label><label class='operateName' title='"+d.operateName+"'>"+d.operateName+"</label><label class='operateTypeName' title='"+d.operateTypeName+"'>"+d.operateTypeName+"</label></span></TD></TR>";

                $(".gjmultiple").prepend(lis);

            })
            return lis;
        }
    });

    $.extend({
        multiplegzjlfoss: function (rs) {
            var lis = "";
            $(rs).each(function (i, d) {
                if(null==d){
                    return;
                }

                var createTimeStr = d.createTime+"";

                if(createTimeStr!=null&&createTimeStr!=''){
                    if(createTimeStr>999999999){
                        createTimeStr = parseInt(createTimeStr/1000) ;
                    }
                }

                var acceptedTimeStr = d.acceptedTime+"";

                if(acceptedTimeStr!=null&&acceptedTimeStr!=''){
                    if(acceptedTimeStr.length>10){
                        acceptedTimeStr = parseInt(acceptedTimeStr/1000);
                    }
                }

                var unixTimestamp = new Date( createTimeStr*1000 ) ;
                var commonTime = unixTimestamp.toLocaleString();
                var datestrformate = commonTime.split("&");
                var unixTimestampsl = new Date( acceptedTimeStr*1000 ) ;
                var commonTimesl = unixTimestampsl.toLocaleString();
                var datestrformatesl = commonTimesl.split("&");

                var qctime ="";
                (null == d.createTime) ? qctime = "" : qctime =  "<label>起草</label>"+datestrformate[0]+" "+datestrformate[1];

                var sltime="";
                (null == d.acceptedTime) ? sltime = "" : sltime = "<label>受理</label>"+datestrformatesl[0]+" "+datestrformatesl[1];

                var contentgzjl = d.trackContent;
                (null == d.trackContent) ? contentgzjl = "" : contentgzjl = d.trackContent;

                var createOrgNamegzjl = d.createOrgName;
                (null == d.createOrgName) ? createOrgNamegzjl = "" : createOrgNamegzjl = d.createOrgName;

                var acceptedOrgNamegzjl = d.acceptedOrgName;
                (null == d.acceptedOrgName) ? acceptedOrgNamegzjl = "" : acceptedOrgNamegzjl = d.acceptedOrgName;

                var imgstrone =  "<img src='resources/img/multiple/mul-zdfour-gzjl.png' />";

                lis ="<TR class='full'><TD class='trajectory-font'>"+imgstrone+"<span title='"+contentgzjl+"'>"+controlLength(contentgzjl,30)+"</span></TD><TD class='trajectory-info dept'><span>"+qctime+"</span><p>"+controlLength(createOrgNamegzjl,14)+"</p></TD>"+"</TD><TD class='trajectory-info'><span>"+sltime+"</span><p>"+controlLength(acceptedOrgNamegzjl,14)+"</p></TD></TR>";

                $(".gzjlmultiple").prepend(lis);
            })
            return lis;

        }
    });


}

function substrWaybillNo(e) {
    var str = e.substring(0, 3)+" "+e.substring(3, 6)+" "+e.substring(6);
    return str;
}

function checkWaybill(multiplequerywaybillno){
    var waybill = multiplequerywaybillno;
    if(null==waybill||waybill.length==0)
    {
        $(".input-tip").css("display","block");
        $(".input-tip").html("请输入运单号！");
        // $(".multiplequerywaybillno").addClass('error');

        //multiplequerywaybillno
        //confirm("请输入运单号！");
        return false;
    }
    var waybillreg = /^\d{8,10}$/,
        waybillreg2 = /^\d{14}$/;
    var r = waybill.match(waybillreg),
        r2 = waybill.match(waybillreg2);

    if( !(null != r2 || null != r)){
        $(".input-tip").css("display","block");
        $(".input-tip").html("请输入正确的运单号！");
        // $(".multiplequerywaybillno").addClass('error');

        //confirm('请输入正确的运单号！');
        return false;
    }
    $(".input-tip").css("display","none");
    // $(".multiplequerywaybillno").removeClass('error');


}

//vue
function checkWaybillV1(multiplequerywaybillno){
    var waybill = multiplequerywaybillno;
    if(null==waybill||waybill.length==0)
    {
        $(".input-tip").css("display","block");
        $(".input-tip").html("请输入运单号！");
        // $(".multiplequerywaybillno").addClass('error');
        return '';
    }
    var waybillreg = /^\d{8,10}$/,
        waybillreg2 = /^\d{14}$/,
        waybillreg3 = /^[a-zA-Z][a-zA-Z0-9]+$/;
    var r = waybill.match(waybillreg),
        r2 = waybill.match(waybillreg2),
        r3 = waybill.match(waybillreg3);

    if(r3){
        return 'DD';
    }


    if(r2 || r){
        return 'YD';
    }

    return 'QT';
}


function dealShowFirstMenu(){
    $("#selemenu").parent().next().slideToggle();
    $("#selemenu").parents().siblings().find(".csssuper").slideUp();

}

$('.csssuper-div-header').click(function(){
    var $this = $(this);
    var $current = $('.csssuper-div-header.active');
    if ($this.hasClass('active')) {
        $this.next().slideUp("fast");
        $this.removeClass('active');
    } else if ($current.length == 0) {
        $this.next().slideDown("fast");
        $this.addClass('active');
    } else {
        $current.next().slideUp("fast");
        $current.removeClass('active');
        $this.next().slideDown("fast");
        $this.addClass('active');
    }
});

Date.prototype.toLocaleString = function() {
    return  returnMulTimeTwoStr(this.getHours()) + ":" + returnMulTimeTwoStr(this.getMinutes()) + "& " + returnMulTimeTwoStr((this.getMonth() + 1)) + "-" + returnMulTimeTwoStr(this.getDate()) ;
};

function returnMulTimeTwoStr(timeStr){
    if(timeStr>9){
        return timeStr+"";
    }else{
        return "0"+timeStr;
    }
}

function queryGjhwzt(str){
    var strgj="";
    var gjhwztstr = ["OPT_SEPARATE_AIRPORT_SCAN","PC_INVALID","NOTICE_BEFORE","TRACK_RECEIVE","TRACK_STOCK","DELIVERING","NORMAL_SIGN","UNNORMAL_SIGN","ARRIVED","PUSH_STORE","OUT_STORE","HAVE_RETENTION","LDP_DELIVERY","LDP_DELIVERY_FAILURE","LDP_DELIVERY_SUCCESS","LDP_ARRIVALS","LDP_WITHDRAW_DEPPON","KD100_NORMAL_SIGN","KD100_LEAVE","KD100_DELIVERY","KD100_DELIVERY_FAILURE","HGJ_DELIVERY_FAILURE","HGJ_CUSTOMS_ARRIVAL","HGJ_ARRIVALS","HGJ_WITHDRAW_DEPPON","HGJ_DELIVERY","HGJ_NORMAL_SIGN","SDLR_DEPARTURE","SDLR_ARRIVALS","SDLR_DELIVERY","JJD_HANDOVER_BILL","WFD_OUTWARD_BILL","OPT_OUT_CAR","OPT_OUT_CAR_SCAN","OPT_ARRIVAL","OPT_CAR_SCANING","OPT_OUT_STORE","OPT_TRANSPORT","OPT_PACKAGE","OPT_SEPARATE_SCAN","OPT_STOCKING","OPT_STORAGE","OPT_SENDING","AIR_HANDOVER_BILL","AIR_TAKE_OFF","AIR_ARRIVE","HGJ_TRANSPORT_FIELD_ARRIVAL","HGJ_DELIVERY_FAILURE","STA_INBOUND","STA_STATION_REJECT","STA_SIGN","STA_BUYER_REJECT","STA_ADMIN_PICKUP","STA_MAILMAN_PICKUP","STA_PICKUP_TIMEOUT","REVERSESIGN","REVERS_PAYMENT","ALREADY_PDA_ACTIVE","OPT_FINDING","INVALID_JJD_HANDOVER_BILL","OPT_SEPARATE_AIRPORT_SCAN"];
    var gjhwztzwstr=["运输中","已作废","提前通知","接货中","库存中","派送中","正常签收","异常签收","已到达","已入库","已出库","已滞留","派送","疑难件","派送完成","已到达","疑难件","正常签收","运输中","派送","疑难件","疑难件","运输中","已到达","疑难件","派送","正常签收","已出发","已到达","派送","已出库","已出库","卸车中","已卸车","进入货区","待出库","已出库","运输中","已建包","上分拣","库存中","已入库","派送中","制作航空正单","航班起飞","航班到达","运输中","疑难件","入柜，入驿站","站点拒收","正常签收","客户拒收","货物取出","货物取出","入柜超时","反签收","反结清","已补录","已找到","库存中","运输中"];
    for (var i = 0; i < gjhwztstr.length; i++) {
        if (gjhwztstr[i] == str) {
            strgj=gjhwztzwstr[i];
            break;
        }
    }
    return strgj;
}

function queryGjczzt(str){
    var strgj="";
    var gjczztstr = ["MANAGER_ASSIGN","AIRPORT_SCAN_TRAJECTORY","SYSTEM_ASSIGNMENT","DELIVER_CONNECTING","REVERSE_DELIVER_CONNECTING","CONTACT_BYPHONE","DISPATCHRETURN","TEMPORARY_COLLECPOINT","TWO_DELIVERIES","PDA_GOT","PDA_ACTIVE","DELIVERING","NORMAL_SIGN","UNNORMAL_SIGN","PC_GOT","CREATE_DELIVERTASK","DELIVER_SCAN","SUBMIT_DELIVERTASK","TO_DELIVERING","RR_HANDOVER","RETENTION_FLAG","PRE_DELIVER","LDP_DELIVERY","LDP_DELIVERY_FAILURE","LDP_DELIVERY_SUCCESS","LDP_ARRIVALS","LDP_WITHDRAW_DEPPON","KD100_NORMAL_SIGN","KD100_LEAVE","KD100_DELIVERY","KD100_DELIVERY_FAILURE","HGJ_DELIVERY_FAILURE","HGJ_CUSTOMS_ARRIVAL","HGJ_ARRIVALS","HGJ_WITHDRAW_DEPPON","HGJ_DELIVERY","HGJ_NORMAL_SIGN","SDLR_DEPARTURE","SDLR_ARRIVALS","SDLR_DELIVERY","JJD_HANDOVER_BILL","WFD_OUTWARD_BILL","SCAN_WAYBILL_TRAJECTORY","DEPART_TRAJECTORY","ARRIVE_TRAJECTORY","SORT_SCAN_TRAJECTORY","LESS_GOODS","FINDING_LESS_GOODS","UNLOAD_GOODS_MORE","PARTNER_BEGIN","PARTNER_DEPARTMENT","PARTNER_END","PARTNER_SEND","IN_STORAGE","OUT_PARTNER_STORAGE","OUT_BUSINESS_STORAGE","INVALID_STORE","AIR_HANDOVER_BILL","AIR_TAKE_OFF","AIR_ARRIVE","HGJ_TRANSPORT_FIELD_ARRIVAL","HGJ_DELIVERY_FAILURE","CREATE_UNLOAD_TASKTRAJECTORY","TRAY_SCAN_WAYBILLTRAJECTORY","UNLOAD_SCAN_WAYBILLTRAJECTORY","SUBLOAD_TASKWAYBILL_TRAJECTORY","MAKE_HANDOVER_BILLWAYTRAJECTORY","SUBMIT_PACKAGE_TRAJECTTORY","SINGLE_TRICKET","SETOUT_BEGIN","ARRIVED_END","CHANGE_GOT","CLEARANCE_MORE","STA_INBOUND","STA_STATION_REJECT","STA_SIGN","STA_BUYER_REJECT","STA_ADMIN_PICKUP","STA_MAILMAN_PICKUP","STA_PICKUP_TIMEOUT","REVERSESIGN","REVERS_PAYMENT","CHANGE_SIGN_RESULT","OPERATE_TYPE_SD_TRACK_TRANSFER","PDA_PTP_LOAD","PDA_PTP_UNLOAD","NOLABEL_CLEARANCE_MORE","PEOPLE_LESSFIND_GOODS","PEOPLE_LESS_GOODS","INVALID_JJD_HANDOVER_BILL","OUT_COURIER_STOCK","IN_COURIER_STOCK","MANAGER_ASSIGN","AIRPORT_SCAN_TRAJECTORY"];
    var gjczztzwstr=["经理指派","机场扫描","系统指派","派送交单","撤销派送交单","电话联系","调度退单","代收点暂存","二次派送","PDA开单","运单补录","派送中","正常签收","异常签收","悟空开单","创建派送任务","派件扫描","提交派送任务","待派送转派送","人人交接","滞留标记","预派送","派件出仓","派件失败","派件成功","到达网点","疑难件","正常签收","快递代理公司外发","快递代理公司派送","快递代理公司派送失败","快递代理公司派送失败","清关到达","到达目的站","已退回","快递代理派送","正常签收","出发","到达","派件","快递代理交接","快递代理外发单录入","装车扫描","出发 ","到达","上分拣扫描","少货入库到特殊组织","少货找到","卸车多货","合伙人出发交接","到达营业部","合伙人到达交接","派送","入库","合伙人交接出库","自营交接出库","作废交接单重新入库","制作航空正单","航班起飞","航班到达","转运场到达","快递代理派送失败","建立卸车任务","叉车司机扫描","卸车扫描","提交装车任务","出发交接","提交建包任务","单票入库","出发","到达","转寄开单","清仓多货","入柜，入驿站","站点拒收","用户提货","消费者拒收","管理员取出","快递员取出","柜子超时","反签收","反结清","变更签收结果","转寄退回出库","PDA装车扫描","PDA卸车扫描","无标签多货认领入库","人工上报丢货找到入库","人工上报丢货入库","修改交接入库","登出快递异常库区","登入快递异常库区","经理指派","机场扫描"];
    for (var i = 0; i < gjczztstr.length; i++) {
        if (gjczztstr[i] == str) {
            strgj=gjczztzwstr[i];
            break;
        }
    }
    return strgj;
}

$(function () {
    var $inputgroupselect = "<i class='fa fa-fw fa-caret-down'></i>";
    $(".input-group-select .dropdown .dropdown-menu>li").click(function () {
        var $precontentcss = $(this).context.textContent;
        if("人员"==$precontentcss){
            $(".oaDepartSearch").slideUp("fast");
            $(".csssuper").slideUp("fast");
            $(".csssuper-order").slideUp("fast");
            $("#selemenu").find("input").attr("placeholder","请输入姓名/工号/手机");
            $("#selemenu").find("input").val("");
        }
        if("部门"==$precontentcss){
            $(".oaClerkSearch").slideUp("fast");
            $(".csssuper").slideUp("fast");
            $(".csssuper-order").slideUp("fast");
            $("#selemenu").find("input").attr("placeholder","请输入部门名称");
            $("#selemenu").find("input").val("");
        }if("运单/订单"==$precontentcss){
            $(".oaDepartSearch").slideUp("fast");
            $(".oaClerkSearch").slideUp("fast");
            $("#selemenu").find("input").attr("placeholder","搜索运单/订单");
            $("#selemenu").find("input").val("");
        }
        // alert($precontentcss);
        $(".input-group-select .dropdown .dropdown-toggle").html($precontentcss+$inputgroupselect);
    });

});

/*************************************通讯录部门展示***************************************************/
$(function () {
    // 大部门展示小部门
    $('.oaDepartSearch').find('.childDepart_table tr').click(function () {
        $('.oaDepartSearch').slideUp('500');
        // waitTimer('500');
        $('.oaDepartSearch').slideDown('500');
    })
    // 点击小部门返回大部门
    $('.oaDepartSearch').find('.childDepartName').click(function () {
        $('.oaDepartSearch').slideUp('500');
        // waitTimer('500');
        $('.oaDepartSearch').slideDown('500');
    })
})


function returnTimeTwoStrMul(timeStr){
    if(timeStr>9){
        return timeStr+"";
    }else{
        return "0"+timeStr;
    }
}

